package net.sf.yacas;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class DefaultIstreamFactory implements Function<String, InputStream> {

	@Override
	public InputStream get(String name) {
		InputStream is = getClass().getResourceAsStream(name);
	    if (is == null)
	      is = getClass().getResourceAsStream("/" + name);
	    if (is == null) {
	      try {
	        is = new BufferedInputStream(new FileInputStream(name));
	      } catch (FileNotFoundException e) {
	        is = null;
	      }
	    }
	    return is;
	}

}
